package com.telecom.cms.dbconnect;

import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.dbcp.BasicDataSource;

import com.telecom.cms.util.Constant;
import com.teradata.db.*;
import com.teradata.tap.system.query.QueryException;

/**
 * @author yueyingnishang
 * 
 */
public class GetConnectbak {

	private final static int poolsize = 50;

	private static BasicDataSource ds = null;

	private static Connection[] con = new Connection[poolsize];

	/**
	 * @return
	 */
	public static Connection getConnection() {
		return com.telecom.cms.dao.GetConnect.getCsConnection();
		
		    /*int rand = (int) Math.floor(Math.random() * poolsize);


			if (Constant.myContainer.equalsIgnoreCase("TOMCAT")) {
	
				if (con[rand] == null) {

					if (ds == null) {

						ds = new BasicDataSource();

						ds.setDriverClassName("com.ncr.teradata.TeraDriver");

						ds

								.setUrl("jdbc:teradata://133.0.177.10/CLIENT_CHARSET=CP936,TMODE=TERA,CHARSET=ASCII,database=TD_CMS,LOB_Support=OFF");

						ds.setUsername("pu_cms");

						ds.setPassword("yuancms1271");

						ds.setMaxActive(0);

						ds.setInitialSize(poolsize+2); //初始化连接数量

						ds.setMaxIdle(0); //最大idle数

						ds.setMaxWait(1000 * 120); //超时回收时间

					}

					try {

						con[rand] = ds.getConnection();

					} catch (Exception e) {

						// TODO Auto-generated catch block

						e.printStackTrace();

						System.out.println(e.toString()+ds.getNumIdle()+rand);

					}

			} 
				
				
			}	else if (Constant.myContainer.equalsIgnoreCase("JBOSS")) {
				DBConnection dbConn = new DBConnection();
				// 从TAP的默认Datasource中获取Connection
				// Connection conn=dbConn.getConnFromDS();
				try {
					con[rand] = dbConn.getConnFromDS("java:jdbc/TeradataCMS");
				} catch (QueryException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		

		return con[rand];*/
	}
}
